package com.itheima;

import com.itheima.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author: dh
 * @date: 2023-10-25 09:14
 */
public class AppForDiConstructor {

    public static void main(String[] args) {

        // 1.获得IoC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 2.通过getBean方法获得对象.
        BookService bookService = (BookService) ctx.getBean("bookService");
        // 3.调用对象中的方法。
        bookService.save();
    }
}
